<template>
  <view
    class="uni-calendar-item__weeks-box"
    :class="{
      'uni-calendar-item--multiple': weeks.multiple,
      'uni-calendar-item--after-checked':weeks.afterMultiple,
    }"
    @click="choiceDate(weeks)"
  >
    <view class="uni-calendar-item__weeks-box-item">
      <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle" />
      <!-- 上面数据 -->
      <text
        v-if="!lunar&&!weeks.extraInfo && weeks.isDay"
        class="uni-calendar-item__weeks-box-text"
        :class="{
          'uni-calendar-item--isDay-text': weeks.isDay,
          'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
          'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay && date,
          'uni-calendar-item--before-checked':weeks.beforeMultiple,
          'uni-calendar-item--multiple': weeks.multiple,
          'uni-calendar-item--after-checked':weeks.afterMultiple,
          'uni-calendar-item--disable':weeks.disable || !weeks.haveTicket,
        }"
      >今天</text>
      <text
        v-if="lunar&&!weeks.extraInfo"
        class="uni-calendar-item__weeks-box-text"
        :class="{
          'uni-calendar-item--isDay-text': weeks.isDay,
          'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
          'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && date,
          'uni-calendar-item--before-checked':weeks.beforeMultiple,
          'uni-calendar-item--multiple': weeks.multiple,
          'uni-calendar-item--after-checked':weeks.afterMultiple,
          'uni-calendar-item--disable':weeks.disable || !weeks.haveTicket,
        }"
      >{{ weeks.isDay?'今天': weeks.date }}</text>
      <!-- 下面数据 -->
      <text
        class="uni-calendar-item__weeks-lunar-text"
        :class="{
          'uni-calendar-item--isDay-text-bottom':weeks.isDay,
          'uni-calendar-item--checked-bottom':calendar.fullDate === weeks.fullDate && date,
          'uni-calendar-item--before-checked':weeks.beforeMultiple ,
          'uni-calendar-item--multiple': weeks.multiple,
          'uni-calendar-item--after-checked':weeks.afterMultiple,
          'uni-calendar-item--disable':weeks.disable || !weeks.haveTicket,
          'uni-calendar-item--opacity':!price && weeks.haveTicket,
        }"
      >{{ weeks.haveTicket ? '¥'+price :'暂未开放' }}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    weeks: {
      type: Object,
      default() {
        return {}
      }
    },
    calendar: {
      type: Object,
      default: () => {
        return {}
      }
    },
    selected: {
      type: Array,
      default: () => {
        return []
      }
    },
    lunar: {
      type: Boolean,
      default: false
    },
    date: {
      type: String,
      default: null
    },
    price: {
      type: String,
      default: null
    }
  },
  methods: {
    choiceDate(weeks) {
      this.$emit('change', weeks)
    }
  }
}
</script>

<style lang="scss" scoped>
.uni-calendar-item__weeks-box {
  flex: 1;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.uni-calendar-item__weeks-box-text {
  color: $uni-text-color;
  width: 52rpx;
  height: 52rpx;
  // background-color: blue;
  font-size: 28rpx;
  border: 2rpx solid #ffffff;
  text-align: center;
  line-height: 52rpx;
  border-radius: 8rpx;
}

.uni-calendar-item__weeks-lunar-text {
  font-size: $uni-font-size-sm;
  color: $uni-text-color;
}
.uni-calendar-item--opacity {
  opacity: 0;
}
.uni-calendar-item__weeks-box-item {
  position: relative;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100rpx;
  height: 100rpx;
}

.uni-calendar-item__weeks-box-circle {
  position: absolute;
  top: 10rpx;
  right: 10rpx;
  width: 16rpx;
  height: 16rpx;
  border-radius: 16rpx;
  background-color: $uni-color-error;
}

.uni-calendar-item--disable {
  background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  color: #cccccc;
}

.uni-calendar-item--isDay-text {
  background-color: #306de9;
  opacity: 0.8;
  color: #fff;
  width: 52rpx;
  height: 52rpx;
  // background-color: blue;
  font-size: 24rpx;
  border: 2rpx solid #ffffff;
  text-align: center;
  line-height: 52rpx;
  border-radius: 8rpx;
}

.uni-calendar-item--isDay {
  background-color: #306de9;
  opacity: 0.8;
  color: #fff;
  width: 52rpx;
  height: 52rpx;
  // background-color: blue;
  font-size: 24rpx;
  border: 2rpx solid #ffffff;
  text-align: center;
  line-height: 52rpx;
  border-radius: 8rpx;
}

.uni-calendar-item--extra {
  color: $uni-color-error;
  opacity: 0.8;
}

.uni-calendar-item--checked {
  // background-color: $uni-color-primary;
  color: #306de9;
  opacity: 0.8;
  width: 52rpx;
  height: 52rpx;
  background-color: #eaf0fc;
  font-size: 24rpx;
  border: 2rpx solid #306de9;
  font-weight: bold;
  text-align: center;
  line-height: 52rpx;
  border-radius: 8rpx;
}
.uni-calendar-item--checked-bottom {
  color: #306de9;
}
.uni-calendar-item--multiple {
  background-color: $uni-color-primary;
  color: #fff;
  opacity: 0.8;
}
.uni-calendar-item--before-checked {
  background-color: #ff5a5f;
  color: #fff;
  width: 56rpx;
  height: 56rpx;
}
.uni-calendar-item--after-checked {
  background-color: #ff5a5f;
  color: #fff;
}
</style>
